<template>
  <div class="container">
    <h3 style="text-align:center;">校区信息添加</h3>
    <hr />
    <div id="compus_ruleForm" style="margin:auto;text-align:center;width:80%">
      <el-form
        :model="compus_ruleForm"
        status-icon
        :rules="rules"
        ref="compus_ruleForm"
        inline-message
        class="demo-ruleForm"
      >
        <el-form-item prop="compusName">
          <span>校区名称：</span>
          <el-input v-model="compus_ruleForm.compusName"></el-input>
        </el-form-item>
        <el-form-item prop="compusEnglishName">
          <span>校区英文名称：</span>
          <el-input v-model="compus_ruleForm.compusEnglishName"></el-input>
        </el-form-item>
        <el-form-item prop="officePhone">
          <span>校区办公室电话：</span>
          <el-input v-model="compus_ruleForm.officePhone"></el-input>
        </el-form-item>
        <el-form-item prop="address">
          <span>地址：</span>
          <el-input v-model="compus_ruleForm.address"></el-input>
        </el-form-item>
        <el-form-item prop="postCode">
          <span>邮政编码：</span>
          <el-input v-model="compus_ruleForm.postCode"></el-input>
        </el-form-item>
        <el-form-item>
          <span style="width:80%;text-align:center;">
            <el-button type="primary" @click="submitForm('compus_ruleForm')">提交</el-button>
            <el-button type="primary" @click="resetForm('compus_ruleForm')">重置</el-button>
            <!-- <el-button type="primary" @click="back">返回</el-button> -->
          </span>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: "Add",
  data() {
    return {
      compus_ruleForm: {
        // compusId: "", //校区编号
        compusName: "", //校区名称
        compusEnglishName: "", //英文名称
        officePhone: "", //办公室电话
        address: "", //校区地址
        postCode: "" //邮政编码
      },
      rules: {
        compusName: [
          { required: true, message: "请输入校区名称", trigger: "blur" }
        ],
        compusEnglishName: [
          { required: true, message: "请输入校区英文名称", trigger: "blur" }
        ],
        officePhone: [
          { required: true, message: "请输入办公室电话号码", trigger: "blur" }
        ],
        address: [
          { required: true, message: "请输入校区地址", trigger: "blur" }
        ],
        postCode: [
          { required: true, message: "请输入校区邮政编码", trigger: "blur" }
        ]
      }
    };
  },
  methods: {
    //教师授课意向表表单提交
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    //表单重置
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }
};
</script>

<style scoped>
#container {
  width: 80%;
  margin: auto;
  font-size: 20px;
}
span {
  display: inline-block;
  width: 200px;
  font-size: 20px;
  text-align: right;
}
</style>
<style>
#compus_ruleForm .el-form-item {
  /* display: inline-block;
  text-align: center; */
  height: 50px;
  line-height: 50px;
}
#compus_ruleForm .el-form-item .el-input {
  width: 400px;
  text-align: left;
  height: 50px;
  line-height: 50px;
}
</style>
